package com.macro.mall.pms.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 商品详情
 * 数据结构参考有赞vant sku
 *
 * @author xuyanjun
 * @date 2019-12-14
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@ApiModel(value = "ProductDetail", description = "商品详情")
public class ProductDetail extends Product {


    /**
     * sku
     */
    private Sku sku;

    @Getter
    @Setter
    @Accessors(chain = true)
    public static class Sku {

        @JsonProperty(value = "tree")
        private List<SkuTree> skuTrees;

        /**
         * skuList
         */
        private List<Map<String, Object>> list;

        private BigDecimal price;

        /**
         * 是否无规格商品
         */
        @JsonProperty(value = "none_sku")
        private Boolean noneSku;

        /**
         * 商品总库存
         */
        @JsonProperty(value = "stock_num")
        private Integer stockNum;

        /**
         * 是否隐藏库存
         */
        @JsonProperty(value = "hide_stock")
        private Boolean hideStock;
    }

    @Getter
    @Setter
    @Accessors(chain = true)
    public static class SkuTree {

        @JsonProperty(value = "k")
        private String skuKeyName;

        @JsonProperty(value = "v")
        private List<SkuValue> skuValues;

        @JsonProperty(value = "k_s")
        private String skuKeyStr;
    }

    @Getter
    @Setter
    @Accessors(chain = true)
    public static class SkuValue {

        private String id;

        private String name;

        private String imgUrl;

        private String previewImgUrl;
    }
}
